#ifndef ROUTEPLANNING_H
#define ROUTEPLANNING_H
#include <QObject>
#include <QSqlDatabase>
#include<QSqlQuery>
#include <QMainWindow>
#include <QDebug>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <stack>

/******************************
 * 路径选择头文件
 *
 * 2021/3/12  1.0版
 * 2021/3/15  2.0版
 * 2.21/3/20  3.0版
 * 2021/3/25  4.0版
 *  金雨展
 * *******************************
 */


typedef struct Node{
    int f;//总路程
    int g;//当前cost
    int h;//启发式函数
    QString id; //城市的序号
    QString father_id;
    double cost;
    double fee;
    Node() {
        f = 0;
        g = 0;
        h = 0;
        id = -1;
        father_id = -1;
        cost = 0;
    }
    Node(int g, int h, QString id, QString father_id,double cost,double fee){
        this->h = h;
        this->g = g;
        this->id = id;
        this->f = g+h;
        this->father_id = father_id;
        this->cost = cost;
        this->fee = fee;
    }
}NN;


typedef struct{
    QString a;
    QString b;
    int way;
    double timeCost;
    double fee;

}ZZ;



class RoutePlanning
{
public:
    RoutePlanning();
    bool a_star(int waynum, QString start, QString end,int type);
    QList<QString> find(QString start,QString end,int type);
    //QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
    int readDist();
    double strai_dist(QString jingguo, double x2,double y2);
    QList<QString> city;
private:

    QVector<NN> openLists;
    QVector<NN> closeLists;
    double getH(QString jingguo1, QString jingguo2,QString mubiao);
    double strai_dist(QString jingguo, QString mubiao);
    static bool cmp(const NN &node1, const NN &node2);
    bool node_in(QString id, QVector<NN> List);
    Node findNode_byId(QVector<NN> list, QString id);

};

#endif // ROUTEPLANNING_H
